window.modifyUserPassword = function(needParam){ 
    Ext.Ajax.request({
        url: 'user_view.action',
        method: 'post',
        params: {
            userId: needParam
        },
        success: function(resp, opts){
            var respText = Ext.util.JSON.decode(resp.responseText);
            if (respText.success) {
                password_window = new Ext.Window({
                    title: '修改密码',
                    iconCls: 'user_password',
                    width: 320,
                    resizable: false,
                    autoHeight: true,
                    modal: true,
                    closeAction: 'hide',
                    closable : false,
                    items: [modify_password_form = new Ext.FormPanel({
                        border: false,
                        id: 'modifyUserPassword',
                        baseCls: 'x-plain',
                        bodyStyle: 'padding:5px 5px 0',
                        labelAlign: 'right',
                        labelWidth: 100,
                        defaults: {
                            itemCls: 'form_text',
                            msgTarget: 'side'
                        },
                        defaultType: 'textfield',
                        items: [{
                            fieldLabel: '用户名',
                            name : 'user.userName',
                            value: respText.user.userName,
                            itemCls: 'form_text unedit',
                            readOnly: true
                        }, {
                            fieldLabel: '原密码',
                            inputType: 'password',
                            allowBlank: false,
                            regex: /^[A-Za-z0-9]{6,11}$/,
                            regexText: '密码只能为6~11位的数字或字母组合',
                            name: 'oldPassword'
                        }, {
                            fieldLabel: '新密码',
                            inputType: 'password',
                            name: 'newPasswordTwo',
                            id:'newPasswordTwo',
                            regex: /^[A-Za-z0-9]{6,11}$/,
                            regexText: '密码只能为6~11位的数字或字母组合',
                            allowBlank: false
                        }, {
                            fieldLabel: '确认密码',
                            inputType: 'password',
                            name: 'confirmNewPasswordFour',
                            id:'confirmNewPasswordFour',
                            regex: /^[A-Za-z0-9]{6,11}$/,
                            regexText: '密码只能为6~11位的数字或字母组合',
                            allowBlank: false
                        }]
                    
                    })],
                    buttons: [{
                        text: '确定',
                        type: 'submit',
                        handler: function(){
                        
	                    	var newPasswordTwo = Ext.getCmp('newPasswordTwo').getValue();
	     	     			var confirmNewPasswordFour = Ext.getCmp('confirmNewPasswordFour').getValue();
	     	     			if(confirmNewPasswordFour != newPasswordTwo)
	     	     			{
	     	     				Ext.Msg.show({
	     							title : '错误提示',
	     							msg : '确认新密码必须和新密码一致',
	     							buttons : Ext.Msg.OK,
	     							icon : Ext.Msg.INFO,
	     							width : 200
	     						});
	     						return;
	     	     			} 
                            
                            if (modify_password_form.form.isValid()) {
                                modify_password_form.form.doAction('submit', {
                                    url: 'user_password_edit.action',// 文件路径
                                    method: 'post',// 提交方法post或get
                                    params: '',
                                    success: function(form, action){
                                        if (action.result.msg == 'wrong') {
                                            Ext.Msg.show({
                                                title: '错误提示',
                                                msg: '原密码错误',
                                                buttons: Ext.Msg.OK,
                                                icon: Ext.Msg.ERROR,
                                                width: 200
                                            });
                                        }
                                        else 
                                            if (action.result.msg == 'ok') {
                                                Ext.Msg.show({
                                                    title: '信息',
                                                    msg: '修改密码成功',
                                                    buttons: Ext.Msg.OK,
                                                    icon: Ext.Msg.INFO,
                                                    width: 200
                                                });
                                                password_window.remove(Ext.getCmp('modifyUserPassword'));
                                                password_window.close();
                                            }
                                    },
                                    failure: function(form, action){
                                        if (action.failureType == 'server') {
                                        	Ext.Msg.show({
                                                title: '错误',
                                                msg: action.result.msg,
                                                buttons: Ext.Msg.OK,
                                                icon: Ext.Msg.INFO,
                                                width: 200
                                            });
                                        }
                                        else 
                                            if (action.failureType == 'connect') {
                                                Ext.Msg.alert('连接错误', '指定路径连接错误!');
                                            }
                                            else 
                                                if (action.failureType == 'client') {
                                                    Ext.Msg.alert('提示', '数据错误，非法提交');
                                                }
                                                else {
                                                    Ext.MessageBox.alert('警告', '服务器数据传输错误');
                                                }
                                    }
                                });
                            }
                        }
                    }, {
                        text: '取消',
                        handler: function(){
                    		password_window.remove(Ext.getCmp('modifyUserPassword'));
                            password_window.close();
                        }
                    }]
                }).show();
            }
            else {
            	Ext.Msg.show({
                    title: '错误提示',
                    msg: respText.msg,
                    buttons: Ext.Msg.OK,
                    icon: Ext.Msg.ERROR,
                    width: 200
                });
            }
        },
        failure: function(){
            Ext.Msg.show({
                title: '错误提示',
                msg: '修改失败!',
                buttons: Ext.Msg.OK,
                icon: Ext.Msg.ERROR,
                width: 200
            });
        }
    });
};
